package com.wisdom.springiocdi;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;


@SpringBootApplication
public class SpringIocDiApplication {
//获取Spring上下文对象
    public static void main(String[] args) {
        ApplicationContext context=
        SpringApplication.run(SpringIocDiApplication.class, args);
        //从Spring上下文中获取对象
        UserController userController=context.getBean(UserController.class);
        userController.SayHi();

        UserService service=context.getBean(UserService.class);
        service.SayHi("刘宝强");

        UserRepository userRepository=context.getBean(UserRepository.class);
        userRepository.SayHi();

        UserComponent userComponent=context.getBean(UserComponent.class);
        userComponent.SayHi();

        UserConfiguration userConfiguration=context.getBean(UserConfiguration.class);
        userConfiguration.SayHi();

        User user=context.getBean(User.class);
        System.out.println(user);

    }

}
